package khai.spring;

import com.alibaba.fastjson.JSON;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class ContextListener implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext servletContext = sce.getServletContext();
        String config = servletContext.getInitParameter("config");
        String context = servletContext.getInitParameter("context-param");//只能拿到这个
        System.out.println(config);
        System.out.println(context);
        System.out.println(JSON.toJSON(servletContext));
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }
}
